import requests
from bs4 import BeautifulSoup

def get_stock_news():
    url = "https://so.eastmoney.com/news/s?keyword=贵州茅台&pageindex=1&searchrange=0&sortfiled=4&sorttype=-1"
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
    }
    response = requests.get(url, headers=headers)
    soup = BeautifulSoup(response.text, 'html.parser')
    news_list = []
    for item in soup.find_all('div', class_='news-item'):
        title = item.find('p', class_='title').text
        link = item.find('a')['href']
        news_list.append({'title': title, 'link': link})
    return news_list

if __name__ == "__main__":
    news = get_stock_news()
    for n in news:
        print(f"标题: {n['title']}")
        print(f"链接: {n['link']}")